package Symbol;

import java.util.ArrayList;

import erro.ErroMsgCompilation;

public class VSymbolTable {

	private ArrayList<VSymbol> symbolList;

	public VSymbolTable() {
		symbolList = new ArrayList<VSymbol>();
	}

	public void put(VSymbol symbol) throws ErroMsgCompilation {
		if (!symbolList.contains(symbol)) {
			symbolList.add(symbol);
		}else{
			throw new ErroMsgCompilation("Duplicates declaration identifier: "+symbol.getName());
		}
	}
	
	public VSymbol get(String name, int scopo){
		return symbolList.get(symbolList.lastIndexOf(new VSymbol(name,scopo)));
	}
	
	public static void main(String[] args) throws ErroMsgCompilation {
		VSymbolTable st = new VSymbolTable();
		
		VSymbol[] vs = new VSymbol[10];
		vs[0] = new VSymbol("c",1,Type.INTEGER);
		vs[1] = new VSymbol("d",1,Type.STRING);
		
		st.put(vs[0]);
		st.put(vs[1]);
	}
}
